﻿using Sustainalytics.CRMAddFakeData;
using Sustainalytics.DynamicsCRMGateway;
using Sustainalytics.DynamicsCRMGateway.Entities;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CRMAddFakeData
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var connectionStringSetting = ConfigurationManager.ConnectionStrings["SustainalyticsCRM"];
                if (connectionStringSetting == null)
                    throw new ArgumentException("No CRM connection string specified in the config file!");

                var crmConnectionString = connectionStringSetting.ConnectionString;
                var crmServiceContextFactory = new CrmServiceContextFactory();
                var crmServiceContext = crmServiceContextFactory.GetCrmServiceContext(crmConnectionString);
                var dataProvisioning = new DataProvisioning(
                    new CrmRepository<new_testaccount>(crmServiceContext),
                    new CrmRepository<new_testaccountfeature>(crmServiceContext),
                    new CrmRepository<new_testfeature>(crmServiceContext),
                    new CrmRepository<new_testaccount2>(crmServiceContext),
                    new CrmRepository<new_testfeature2>(crmServiceContext),
                    crmServiceContext);

                dataProvisioning.StoreData();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.ReadKey();
            }

        }
    }
}
